package com.app.newiptv.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 播放源封装
 *
 * @author Richard
 */
public class MediaSource implements Parcelable {
    public interface Type {
        String VOD = "1";
        String ADVERTISEMENT = "9";
        String EPISODE = "10";
        String EPISODE_PREVIDE = "14";
        String SPECIAL = "16";
        String SPECIAL_PREVIDE = "15";
        String LIVE_TV = "1";
    }

    /**
     * 播放源类型,1：普通VOD节目,2：广告,3: 连续剧的单集节目,4：连续剧剧头,5：专辑剧头,6：专题单集节目
     */
    public String type;
    /**
     * 播放源名称
     */
    public String name;
    /**
     * 播放源地址
     */
    public String url;
    /**
     *
     */
    public String parentId;
    /**
     * 节目集ID
     */
    public String id;
    /**
     * 预览图片
     */
    public String previewImg;

    /**
     * 上次播放结束时间
     */
    public int seekPosition = 0;

    public MediaSource() {
        this("", "");
    }

    public MediaSource(String name, String url) {
        this.name = name;
        this.url = url;
        this.type = "";
        this.parentId = "";
        this.id = "";
        this.previewImg = "";
    }

    @Override
    public String toString() {
        return "MediaSource{" +
                "name='" + name + '\'' +
                ", url='" + url + '\'' +
                ", id='" + id + '\'' +
                ", previewImg='" + previewImg + '\'' +
                '}';
    }

    // ---------------------Parcelable implements------------
    public static final Creator<MediaSource> CREATOR = new Creator<MediaSource>() {

        @Override
        public MediaSource createFromParcel(Parcel source) {
            String type = source.readString();
            String name = source.readString();
            String url = source.readString();
            String parentId = source.readString();
            String id = source.readString();
            String previewImg = source.readString();
            int seekPosition = source.readInt();

            MediaSource mediaSourceObj = new MediaSource(name, url);
            mediaSourceObj.type = type;
            mediaSourceObj.parentId = parentId;
            mediaSourceObj.id = id;
            mediaSourceObj.previewImg = previewImg;
            mediaSourceObj.seekPosition = seekPosition;
            return mediaSourceObj;
        }

        @Override
        public MediaSource[] newArray(int size) {
            return new MediaSource[size];
        }

    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(type);
        dest.writeString(name);
        dest.writeString(url);
        dest.writeString(parentId);
        dest.writeString(id);
        dest.writeString(previewImg);
        dest.writeInt(seekPosition);
    }
}
